from lc_frame.utils.log import logger
from fastapi import FastAPI,Body
from lc_frame.lc_intent import lc_intent
import uvicorn
from pydantic import BaseModel

app = FastAPI()
class Item(BaseModel):
    query: str

 

@app.get('/api')
async def root():
    logger.info('API accessed')
    return {'message': 'Hello, World!'}

@app.post('/api/get_answer')
async def answer(query: Item):
    #logger.info('API accessed')
    #que
    r,_,_ = lc_intent.intent_handler(query.query)
    return {"question": query.query,"answer":r }



# if __name__ == '__main__':
#     import uvicorn

#     uvicorn.run(app, host='127.0.0.1', port=8002)
#     logger.info('FastAPI server started')
